package com.administrator.kotlindemo1

import android.content.Intent
import android.view.View
import kotlinx.android.synthetic.main.activity_layout.*


class LayoutActivity : BaseActivity(), View.OnClickListener {


    override fun layoutId(): Int =
            R.layout.activity_layout


    override fun initData() {

    }

    override fun initView() {
        btn_load.setOnClickListener(this)
        btn_error.setOnClickListener(this)
        btn_no_network.setOnClickListener(this)
        btn_startActivity.setOnClickListener(this)
        //赋值后给baseactivity  这样就可以在父类中统一进行错误视图的点击处理 现在是点击后重新加载网络
        mLayoutStatusView = multipleStatusView


//        multipleStatusView.setOnClickListener{
//            Toast.makeText(this,"chongshi",Toast.LENGTH_SHORT).show()}
//
//        multipleStatusView.setOnRetryClickListener {
//            Toast.makeText(this,"chongshi",Toast.LENGTH_SHORT).show() }
    }

    override fun start() {

    }

    override fun onClick(v: View?) {
        when {
            v?.id == R.id.btn_load -> {
                showDialog()
//                multipleStatusView?.showLoading()
            }
            v?.id == R.id.btn_error -> {
                mLayoutStatusView?.showError()
            }
            v?.id == R.id.btn_no_network -> {
                mLayoutStatusView?.showNoNetwork()
            }
            v?.id == R.id.btn_startActivity -> {
                val intent = Intent(this, NetworkActivity::class.java)
                intent.putExtra("username","58888")
                startActivity(intent)

            }

            //还有个布局是空  mlayoutStatusView?.showEmpty()
        }
    }


}
